package com.hongkzh.www.look.enterprise.watch.view.adapter;

import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.hongkzh.www.R;
import com.hongkzh.www.look.enterprise.watch.model.bean.AdvRecommendByAdvIdBean;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by asad on 2018/3/23.
 * 看视频 相关推荐 adapter
 */

public class WSPRvTJAdapter extends RecyclerView.Adapter<WSPRvTJAdapter.ViewHolder> {
    private List<AdvRecommendByAdvIdBean.DataBean> data = new ArrayList<>();

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new ViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_wsprvtj, parent, false));
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        Glide.with(holder.itemView).load(data.get(position).getCoverImgSrc()).into(holder.wsprtIma);
        holder.wsprbTv.setText(data.get(position).getTitle());
    }

    @Override
    public int getItemCount() {
        return data == null ? 0 : data.size();
    }

    public void add(AdvRecommendByAdvIdBean advRecommendByAdvIdBean) {
        data = advRecommendByAdvIdBean.getData();
    }

    static class ViewHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.wsprt_ima)
        ImageView wsprtIma;
        @BindView(R.id.wsprb_tv)
        TextView wsprbTv;

        ViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }
    }
}
